package com.zhss.dfs.datanode.server;

import java.util.concurrent.CountDownLatch;

/**
 * 负责跟一组NameNode中的某一个进行通信的线程组件
 */
public class NameNodeServiceActor {
    /**
     * 向自己负责通信的NameNode进行注册
     */
    public void register(CountDownLatch latch){
        RegisterThread registerThread = new RegisterThread(latch);
        registerThread.start();
    }

    /**
     * 负责注册的线程
     */
    class RegisterThread extends Thread{
        CountDownLatch latch;
        public RegisterThread(CountDownLatch latch){
            this.latch = latch;
        }

        @Override
        public void run() {
            try{
                //发送rpc接口调用请求到NameNode去进行注册
                System.out.println("发送请求到NameNode进行注册。。。。。。");
                String ip = "127.0.0.1";
                String hostname = "dfs-data-01";
                Thread.sleep(1000);
                latch.countDown();
            }catch (Exception e){
                e.printStackTrace();
            }
        }
    }
}
